package com.byxy.service.impl;

import java.util.List;

import javax.annotation.Resource;
import javax.transaction.Transactional;

import org.springframework.stereotype.Service;

import com.byxy.dao.AgencyDao;
import com.byxy.dao.GuideDao;
import com.byxy.dao.LineDao;
import com.byxy.dao.OrderDao;
import com.byxy.entity.Agency;
import com.byxy.entity.Guide;
import com.byxy.entity.Line;
import com.byxy.entity.Order;
import com.byxy.service.OrderService;

@Service
@Transactional
public class OrderServiceImpl implements OrderService {

	@Resource
	private OrderDao orderDao;
	@Resource
	private LineDao lineDao;
	@Resource
	private GuideDao guideDao;
	@Resource
	private AgencyDao agencyDao;

	@Override
	public List<Line> findLine() {
		return lineDao.find();
	}

	@Override
	public List<Order> listAll() {
		return orderDao.find();
	}

	@Override
	public void delete(int id) {
		Order s = new Order();
		s.setId(id);
		orderDao.delete(s);

	}

	@Override
	public void save(Order order) {
		orderDao.add(order);
	}

	@Override
	public Order getById(int id) {
		return orderDao.get(id);
	}

	@Override
	public void update(Order order) {
		orderDao.update(order);
	}

	@Override
	public List<Order> listPage(int page, int rows) {
		int pos = (page - 1) * rows;
		return orderDao.find(pos, rows);
	}

	@Override
	public long count() {
		return orderDao.count();
	}

	@Override
	public List<Agency> findAgency() {
		return agencyDao.find();
	}

	@Override
	public List<Guide> findGuide() {
		return guideDao.find();
	}
}
